#include<iostream>

using namespace std;

class matrix
{
private:

	double distance;
	double angle;

public:

	void set_coordinates(double x, double y)
	{
		distance = x;
		angle = y;
	}

	double ret_distance()
	{
		return distance;
	}

	double ret_angle()
	{
		return angle;
	}

	void transfer()
	{
		double a, b;
		a = distance*cos(angle);
		b = distance*sin(angle);
		cout << a << endl;
		cout << b << endl;
	}
};

void ChekDistance()
{
		cout << "You have entered the negative range " << endl;
		cout << "Enter again: ";
}


int ChekAngel(int angle)
{
	if (angle < 0)
	{
		while (angle < 0)
		{
			angle = angle + 360;
		}
	}
	else
	{
		while (angle > 360)
		{
			angle = angle - 360;
		}
	}
	
	return angle;
}


int main()
{
	double distance;
	double angle;
	cout << "Enter distance and angle:" << endl;
	cout << "distance: ";
	cin >> distance;
	while (distance<0)
	{
		ChekDistance();
		cin >> distance;
	}
	cout << endl;
	cout << "angle: ";
	cin >> angle;
	angle=ChekAngel(angle);
	cout << angle;
	cout << endl;
	matrix a;
	a.set_coordinates(distance, angle);
	a.ret_distance();
	a.ret_angle();
	a.transfer();
	cin.get();
	cin.get();
	cin.get();
	cin.get();

	return 0;
}